사이트 내 전체검색
홈페이지에 2차원 바코드 QR코드 달기 (PHP 구글차트이용)
로빈아빠
https://cmd.kr/javascript/787 URL이 복사되었습니다.

본문

<a href="#" onclick=set_toggle('id_qrcode')>QR code</a>

<?
$url2="http://$_SERVER[HTTP_HOST]"."$_SERVER[REQUEST_URI]";
?>
<div id="id_qrcode" style="z-index:10000;visibility:hidden;display:none"> 
<form name=frm_qrurl method=post onSubmit="return view_qrcode()" style="margin:0px;">
QR:URL<input name=qrurl class=ed size=45 value='<?=$url2?>' title='주소를 입력하고 엔터를 누르면 해당 주소의 URL코드가 우측에 나타닙니다.'>
<img id='img_qrcode' src="http://chart.apis.google.com/chart?cht=qr&chs=120x120&choe=UTF-8&chld=H&chl=<?=urlencode($url2)?>&chld=L|0" title='QR코드 :  <?=htmlspecialchars($g4['title'])?> <?=htmlspecialchars($url2)?>'>
<script>view_flash('/flash/watch.swf','_flash',155,115);</script>
</form>
</div> 

<script>

function view_qrcode() {
var url=document.frm_qrurl.qrurl.value;
document.getElementById("img_qrcode").src="http://chart.apis.google.com/chart?cht=qr&chs=120x120&choe=UTF-8&chld=H&chld=L|0&chl="+URLEncode(url);
return false;
}


function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
     output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


function set_toggle(id) {
var disp=document.getElementById(id);
if (disp.style.visibility) {
disp.style.visibility="";
disp.style.display="block";
set_cookie("set_qrcode",1,30*24*3600);
}
else {
disp.style.visibility="hidden";
disp.style.display="none";
delete_cookie("set_qrcode");
}
}
var disp=document.getElementById('id_qrcode');
if (get_cookie("set_qrcode")) {
disp.style.visibility="";
disp.style.display="block";
}
else {
disp.style.visibility="hidden";
disp.style.display="none";
}
</script>

댓글목록

등록된 댓글이 없습니다.

831 (2/17P)

Search

Copyright © Cmd 명령어 3.145.66.241